package com.zh.webcommon.common.auditor.jpa;

import com.fasterxml.jackson.annotation.JsonIgnore;
import jakarta.persistence.Column;
import jakarta.persistence.MappedSuperclass;
import lombok.Getter;
import lombok.Setter;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 实体公共字段
 *
 * @author ZH
 * @date 23:43 2021/5/15
 */
@Getter
//@EntityListeners(AuditingEntityListener.class)
@MappedSuperclass
public abstract class BaseEntity implements Serializable {

    /**
     * 创建时间
     */
    @Setter
    @CreatedDate
    protected LocalDateTime createTime;
    /**
     * 创建人
     */
    @Setter
    @CreatedBy
    protected String createBy;

    /**
     * 修改时间
     */
    @Setter
    @LastModifiedDate
    protected LocalDateTime updateTime;
    /**
     * 修改人
     */
    @Setter
    @LastModifiedBy
    protected String updateBy;

    /**
     * 逻辑删除标识
     */
    @Column(columnDefinition = " BOOL DEFAULT false")
    @JsonIgnore
    protected boolean deleted;

}
